package com.zkw.gra.dynamic

/**
 * Created by Administrator on 2016/4/11 0011.
 * 高级的方法参数使用
 */
class AdvanceParamMain {
    def sumWithDefault(a,b,c=0){
        a+b+c
    }
    def static sumWithList(List args){
        args.inject (0){sum,i -> println "${i}："+"${sum}";sum+=i}
    }
    def static sumWithOptionals(a,b,Object[] optionals){
        a+b+sumWithList(optionals.toList())
    }
    def static sumNamed(Map args){
        ['a','b','c'].each {args.get(it,0)}//?don't understand
        args.a+args.b+args.c//?
    }
    public static void main(String[] args) {
//        sumWithList([1,2,3])
//        println sumWithOptionals(1,2,1,2)
        println sumNamed(a:1,b:2)
    }
}
